
<?php
	$filename=NV_ROOTDIR."/modules/".$module_name."/admin/config.xml";
	$content="chém người";
	$xpath="xin chao";
	include("addnews.php");
	include("addxpath.php");
	//include("Library.php");
	$xml=new xmlLibrary();
	$deleteNews=$xml->GetValueFromXpath('deleteNews',$filename);
	//if($deleteNews=='true')
//	{
//		$rs=Get::GetByAll();
//		$arr_listcatid=array();
//		$rsNews="";
//		while($row=mysql_fetch_array($rs))
//		{
//			$getid=$row[0];
//			$new_row=allnews::GetByid($row[0]);
//			$result=mysql_fetch_array($new_row);
//			if(NV_CURRENTTIME>$result[10]&&$result[10]!=0)
//			{
//				$arr_listcatid=explode(',',$result[1]);
//				allnews::Delete($row[0]);
//				allnews::DeleteNewsFrom($arr_listcatid,$row[0]);
//				Get::Delete($row[0]);
//			}
//			
//		}
//	}
	if(isset($_POST['Save']))
	{
		$dirimage=NV_BASE_SITEURL . NV_UPLOADS_DIR;
		$new=new news();
		$new->title=$_POST['title'];
		$new->head=$_POST['head'];
		$new->content=$_POST['content1'];
		$new->image=$dirimage.'/3.jpg';
		$new->alias=change_alias($new->title);
		if(isset($_POST['status']))
			$new->status=1;
		else $new->status=0;
		$new1=new news1();
		allnews::Insert($new);
		$id=mysql_insert_id();;
		Get::Insert($id);
		$new1->Insert($new);
	}
	else if(isset($_POST['SaveEdit']))
	{	
		$dirimage=NV_BASE_SITEURL . NV_UPLOADS_DIR;
		$new=new news();
		$new->title=$_POST['title'];
		$new->head=$_POST['head'];
		$new->content=$_POST['content1'];
		$new->image=$dirimage.'/3.jpg';
		$new->alias=change_alias($new->title);
		if(isset($_POST['status']))
			$new->status=1;
		else $new->status=0;
		$new1=new news1();
		allnews::Insert($new);
		$id=mysql_insert_id();
		Get::Insert($id);
		$new1->Insert($new);
		header('Location:index.php?nv=news&op=content&id='.$id);
	}
	//if(isset($_POST['saveconfig']))
//	{
//		$x=new XpathInfo();
//		$x->xpathTitle=$_POST['xpathtitle'];
//		$x->xpathHead=$_POST['xpathhead'];
//		$x->xpathContent=$_POST['xpathcontent'];
//		$x->xpathImage=$_POST['xpathimage'];
//		$x->url='vnexpress.net';
//		$x->domain='vnexpress.net';
//		XpathService::Insert($x);
//	}
?>
<?php
$filegetNew='
<div>
<form action="index.php?nv=getnews" method="post" name="form2">
<input type="hidden" name="xpathtitle" id="xpathtitle"></input>
<input type="hidden" name="xpathhead" id="xpathhead"></input>
<input type="hidden" name="xpathcontent" id="xpathcontent"></input>
<input type="hidden" name="xpathimage" id="xpathimage"></input>
 Nội dung:
  <textarea name="content" id="content" cols="45" rows="5" style="width:100%">'.$content.'</textarea>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="21%"><input type="button"  value="Làm tiêu đề" onclick="document.getElementById(\'title\').value=document.getElementById(\'content\').value;document.getElementById(\'xpathtitle\').value=\''.$xpath.'\'"/></td>
    <td width="23%"><input type="button"  value="Làm tóm tắt" onclick="document.getElementById(\'head\').value=document.getElementById(\'content\').value;document.getElementById(\'xpathhead\').value=\''.$xpath.'\'"/></td>
    <td width="23%"><input type="button"  value="Làm nội dung" onclick="document.getElementById(\'content1\').value=document.getElementById(\'content\').value;document.getElementById(\'xpathcontent\').value=\''.$xpath.'\'"/></td>
    <td width="33%"><input type="button"  value="Làm ảnh thumbnail" onclick=";document.getElementById(\'xpathimage\').value=\''.$xpath.'\'"/></td>
    </tr>
  <tr>
    <td colspan="4"><p>Tiêu đề:</p>
      <p>
        <input name="title" type="text" id="title" value="'.$_POST["title"].'" size="100">
      </p></td>
    </tr>
  <tr>
    <td colspan="4">Tóm tắt
      <textarea name="head" id="head" cols="45" rows="5" style="width:100%">'.$_POST["head"].'</textarea></td>
    </tr>
  <tr>
    <td colspan="4">Nội dung
      <label for="content1">tin:</label>
      <textarea name="content1" id="content1"cols="45" rows="20" style="width:100%">'.$arr_listcatid[1].'</textarea></td>
    </tr>
  <tr>
    <td colspan="4">Ảnh:</td>
    </tr>
 <tr>
 	<td colspan="2"><input type="checkbox" name="status" checked="checked" value="1">Đăng bài viết</input></td>
	<td></td>
	<td><input type="checkbox" name="saveconfig" checked="checked" value="true">Lưu cấu hình lấy tin</input></td>
 </tr>
  <tr>
    <td><input type="submit" value="Lưu bài viết" name="Save"/></td>
    <td><input type="submit" value="Lưu và Chỉnh Sửa" name="SaveEdit"/></td>
    <td></td>
    </tr>
  </table>
</form>
</div>
'
?>